package com.wa.handler;
import cn.hutool.core.lang.Console;
import com.corundumstudio.socketio.AckRequest;
import com.corundumstudio.socketio.SocketIOClient;
import com.corundumstudio.socketio.listener.DataListener;
import com.wa.constants.WebSocketEventConstant;
import com.wa.vo.BomWebSocketPackage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * @author recharde.li@allchips.com
 * @version V1.0
 * @date 2020-07-31 14:07
 **/
@Component
@SuppressWarnings("rawtypes")
public class BomSaasNamespaceMessageEventHandler  implements DataListener<BomWebSocketPackage> {

    final static private Logger logger = LoggerFactory.getLogger(BomNamespaceMessageEventHandler.class);

//    @Resource
//    private IBomSaasWebSocketMessageDispatcherApi bomSaasWebSocketMessageDispatcherApi;

    @Override
    public void onData(SocketIOClient socketIOClient, BomWebSocketPackage pkg, AckRequest ackRequest) {
        try {
            Console.log(pkg);
//            bomSaasWebSocketMessageDispatcherApi.dispatch(pkg, socketIOClient.getSessionId().toString());
        } catch (Exception e) {
            socketIOClient.sendEvent(WebSocketEventConstant.MESSAGE_EVENT, "服务开小差了！");
            logger.error("处理协同前端消息异常", e);
        }
    }

}

